#!/usr/bin/env python3
import rospy
from geometry_msgs.msg import Twist

# 例子：向cmd_vel话题发布移动指令控制小车走圈
def cmd_vel_pub():
    rospy.init_node("draw_circle",anonymous=False)
    cmd_pub = rospy.Publisher("cmd_vel" ,Twist, queue_size=10)
    rate = rospy.Rate(10)
    twist = Twist()     # 速度信息类型
    rospy.loginfo( 'Start Control Robot Draw a circle')
    while not rospy.is_shutdown( ):
        twist.linear.x = 0.2    # 线速度
        twist.angular.z = 0.4   # 角速度
        cmd_pub.publish(twist)
        rate.sleep()

if __name__ == "__main__":
    try:
        cmd_vel_pub()
    except rospy.ROSInterruptException:
        pass